package com.kt.bit.bidw.bizmeta.controller;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kt.bit.bidw.bizmeta.service.MstrIFService;
import com.kt.bit.bidw.common.authority.SessionInfo;
import com.kt.bit.bidw.common.authority.SessionInfoSupport;
import com.kt.bit.bidw.meta.util.KTHashMap;
import com.kt.framework.controller.impl.KTControllerImpl;
import com.kt.framework.exception.BizException;

/**
 * MSTR 연계 정보 관리 Contol Class
 * <br/><b>History</b><br/>
 * <pre>
 * 2012. 5. 4. 최초작성
 * </pre>
 * @author cjsxowls
 * @version 1.0
 */
@Controller(value="mstrIFController")
@RequestMapping(value="/mstrIF.json")
public class MstrIFController extends KTControllerImpl {
	
	private static final Log LOG = LogFactory.getLog(MstrIFController.class); 
	
	@Autowired
	private MstrIFService mstrIFService;

	
	/**
	 * MSTR연계 조직별 리포트 조회 <br>
	 * @param param 조회조건
	 * @return List MSTR 조직별 리포트 목록
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=bizPotalSearchList")
	@ResponseBody
	public Map<String, Object> bizPotalSearchList (
			final HttpServletRequest request,
			@RequestBody final KTHashMap<String, Object> params) throws IOException {   
		if (LOG.isDebugEnabled()) {
			LOG.debug("MstrIFController.bizPotalSearchList Method.");
		}
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return mstrIFService.bizPotalSearchList(params);
		}
	}
}
